<template>
  <div class="search">
    <f-form ref="form" :action="api.invoiceunit" :form-key="this.formItem.invoiceUnitId">
      <f-form-item label="单位名称" :required="true" name="invoiceunitName" :value="formItem.invoiceunitName"/>
     <!-- <f-form-item label="机构" type="select" name="organizationId" :value="formItem.organizationId" :data="api.organization.list" valueKey="organizationId" label-key="organizationName" :required="true" @change="organizationChange"/>
      <f-form-item label="账套" ref="company" type="select" name="companyId" :value="formItem.companyId" :data="api.company.list" valueKey="companyId" label-key="companyName" :required="true" :autoLoad="false"/>-->
      <f-form-item label="税率" :required="true" name="taxNo" :value="formItem.taxNo"/>
      <f-form-item label="电话" :required="true" name="telephone" :value="formItem.telephone"/>
      <f-form-item label="联系人" :required="true" name="linkMan" :value="formItem.linkMan"/>
      <f-form-item label="地址"  name="telephone" :value="formItem.invoiceAddress"/>
      <f-form-item label="签约日期" name="contractDate" :value="formItem.contractDate" type='date'/>
      <f-form-item label="额度开始日期" name="cycleStart" :value="formItem.cycleStart" type='date'/>
      <f-form-item label="总额度" name="totalQuota" :value="formItem.totalQuota"/>
      <f-form-item label="月额度" name="monthQuota" :value="formItem.monthQuota"/>
      <f-form-item label="浮动额度" name="slidingQuota" :value="formItem.slidingQuota"/>
<!--      <a-divider orientation="left">税金账户</a-divider>
      <a-divider orientation="left">返款账户</a-divider>
      -->
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'

  export default {
    name: 'invoiceunitForm',
    props: {},
    data() {
      return {
        refs: this.$refs,
        api: Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          invoiceUnitId: '',
          invoiceunitName: '',
          taxNo: '',
          bankNo: '',
          bankName: '',
          linkMan: '',
          telephone: '',
          organizationId: '',
          companyId: '',
          legalPerson: '',
          legalBankName: '',
          invoiceAddress: '',
          contractDate: null,
          legalBankNo: '',
          cycleStart: '',
          totalQuota: 0,
          monthQuota: 0,
          slidingQuota: 0
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.invoiceUnitId) {
          let params = {
            invoiceUnitId: data.invoiceUnitId
          }
          this.refs['form'].getDetails(params, (data) => {
            //this.$refs['company'].initData()
            this.formItem = data
            this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      organizationChange(value) {
        this.$refs['company'].initData({ organizationId: value })
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({}, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
